using ZeroSum.Models;

namespace ZeroSum.Exceptions;

/// <summary>
/// 异常帮助类（所有异常通过此方法快捷创建）
/// </summary>
public static class Oops
{
    /// <summary>
    /// 发生错误，Error
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static Exception Error(string msg)
    {
        return BusinessException.Of(msg, ResponseStatus.Error);
    }

    /// <summary>
    /// 系统配置异常，SystemConfigurationError
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static Exception SysConfError(string msg)
    {
        return SystemConfigurationError.Of(msg);
    }

    /// <summary>
    /// 数据校验不通过，ValidateFailed
    /// </summary>
    /// <param name="msgList"></param>
    /// <returns></returns>
    public static Exception ValidateFailed(List<string> msgList)
    {
        return ValidateFailedException.Of(msgList);
    }

    /// <summary>
    /// 不支持的操作，NotSupported
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static Exception NotSupported(string msg)
    {
        return NotSupportedException.Of(msg);
    }

    /// <summary>
    /// 未授权 UnAuthorize
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static Exception UnAuthorize(string msg)
    {
        return UnAuthorizeException.Of(msg);
    }

    /// <summary>
    /// 未登录，NeedLogin
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static Exception NeedLogin(string msg)
    {
        return NeedLoginException.Of(msg);
    }

    /// <summary>
    /// 登录过期
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    public static Exception TokenExpired(string msg)
    {
        return TokenExpiredException.Of(msg);
    }

    /// <summary>
    /// 自定义异常
    /// </summary>
    /// <param name="code">状态码</param>
    /// <param name="msg">提示信息</param>
    /// <returns></returns>
    public static Exception Oh(int code, string msg)
    {
        return CustomException.Of(code, msg);
    }
}